package cz.muni.fi.pa165.library.client.gui.swing;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

/**
 *
 * @author Equo
 */
public class LibraryMenuBar extends JMenuBar {
    
    private JMenu mainMenu;
    private JMenuItem aboutItem,exitMenuItem;
    
     
    public LibraryMenuBar() {       
        initializeMenuComponents();
        add(mainMenu);
        setVisible(true);
    }
    
    private void initializeMenuComponents() {
        initializeServerConnectMenuItem();   
    }
    
    private void initializeServerConnectMenuItem() {

        aboutItem = new JMenuItem("About");
        aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
        aboutItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                JFrame aboutProgramFrame = new JFrame("About");
                JLabel creators = new JLabel();
                creators.setText("Information system of a library (pa165). Authors: Abaffy, Foltýnová, Labuda, Ligač ");
                aboutProgramFrame.add(creators);
                aboutProgramFrame.setSize(470, 100);
                aboutProgramFrame.setLocation(Utils.getPointToCenterApplication(470, 100));
                aboutProgramFrame.setVisible(true);
            }
        });
        
        exitMenuItem = new JMenuItem("Exit");
        exitMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        
        mainMenu = new JMenu("Menu");
        mainMenu.setMnemonic(KeyEvent.VK_M);
        mainMenu.add(aboutItem);
        mainMenu.add(exitMenuItem);
        mainMenu.setVisible(true);
         
    }
}
